package com.luanhj.framework.config;

import com.luanhj.framework.tenant.interceptor.TenantInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author luanhj
 * @date 2025/6/3 11:20
 * @description
 **/
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private TenantInterceptor tenantInterceptor;

    /**
     * 添加拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tenantInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/**/login", "/error","/**/captchaImage")
                .excludePathPatterns(
                        "/swagger/**",
                        "/v2/**",
                        "/v3/**",
                        "/webjars/**",
                        "/swagger-resources/**"
                )
                // TODO 下面的要删除
                .excludePathPatterns("/**/tool/gen/**","/**/tenant/**");
    }
}